package com.st.advice;


import com.st.base.BaseResult;

import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class AdviceHandler {

    @ExceptionHandler(value = BindException.class)
    public BaseResult validationHandler(BindException e){
        String defaultMessage = e.getBindingResult().getFieldError().getDefaultMessage();
        return BaseResult.ok(defaultMessage);
    }
}
